package com.fary.condition;

import org.springframework.context.annotation.ConditionContext;
import org.springframework.context.annotation.ConfigurationCondition;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class IfBeanAExistsConfigurationCondition implements ConfigurationCondition {
 
//    @Override
//    public ConfigurationPhase getConfigurationPhase() {
//        return ConfigurationPhase.REGISTER_BEAN;
//    }
 
    @Override
    public ConfigurationPhase getConfigurationPhase() {
        return ConfigurationPhase.PARSE_CONFIGURATION;
    }
 
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        return context.getBeanFactory().containsBeanDefinition("beanA");
    }
}